/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
// 节点范围为[1, 1000]
var isSymmetric = function(root) {
  const iter = (left, right) => {
    if(left == null && right == null) return true
    if(left == null || right == null) return false
    if(left.val == right.val) return iter(left.left, right.right) && iter(left.right, right.left)
    return false
  }
  return iter(root.left, root.right)
 };